#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <errno.h>
#include <arpa/inet.h>
#include <syslog.h>
#include <stdbool.h>

/* port we're listening on */
#define SERVERCLIENT_PORT 3111
#define MAX_MESSAGE_LEN 100
#define SERVER_ACK "ACK"
#define SERVER_ERROR "ERROR"
#define CLIENT_NEW "NEW"
#define CLIENT_CHANGED_PORT "PTR"


struct thread_data{ 
	struct sockaddr_in serveraddr; 
	int listener;
	char data[MAX_MESSAGE_LEN];
 
	/* Counters */
	int num_clients;
	
	/* Thread identification */
	pthread_t thread_id;
	
	/* Client connection descriptor */
	int client_sd;
	
	/* Server */
	bool server_ready;
}; 

/** This structure will return a 
	tokenized string **/
typedef struct msgTokens {
	int size;
	char **tokens;
} msgTokens;

void* Server(void *threadarg);
void* Client(void *threadarg);
void* start_server(void *threadarg);
void* client_send_message (void* threaddata);
